<template>
  <div class="view-item">
    <router-link
      :to="{
        path: '/detail',
        query: {
          field: 'view',
          id: data.id,
        },
      }"
    >
      <div class="img">
        <img :src="data.img" alt="" />
      </div>
      <p class="view-name">
        <span>{{ data.name }}</span>
      </p>
      <p class="stars-score">
        <stars :starNum="Number(data.star)"></stars>
        <span class="score">{{ data.score }}分</span>
      </p>
      <div class="others">
        <span class="price-wrap">
          <span class="price"> ￥{{ data.default_price }} </span>
          <span>起</span>
        </span>

        <span class="cityName">{{ data.city_name }}</span>
      </div>
    </router-link>
  </div>
</template>

<script>
import stars from '../Sub/Star.vue';
export default {
  name: 'ViewItem',
  props: {
    data: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  components: {
    stars,
  },
};
</script>

<style lang="scss" scoped>
.view-item {
  width: 50%;
  padding: 0.1rem;
  box-sizing: border-box;
  background-color: #fff;
  margin-top: 1px;
  .img {
    width: 100%;
    img {
      width: 100%;
      height: 1.2rem;
    }
  }
  .view-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    span {
      font-size: 0.16rem;
      font-weight: bold;
    }
  }
  .stars-score {
    display: flex;
    align-items: center;
    margin: 0.1rem 0;
    .score {
      margin-left: 0.04rem;
      color: orange;
      font-size: 0.16rem;
    }
  }

  .others {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.16rem;
    .price-wrap {
      display: flex;
      align-items: center;
      .price {
        color: #70f1ed;
        margin-right: 0.03rem;
        font-size: 0.2rem;
        font-weight: bold;
      }
    }
  }
}
</style>
